package _99练习;

public class Room extends Thread{
	
	public void run() {
		String [] str= {"穿衣服","刷牙","洗脸","上厕所","吃早饭","整理物品"};
		
			for(int i=0;i<str.length;i++)
			{
				
				if(str[i]=="上厕所")
				{
					synchronized(this) {
						System.out.println(Thread.currentThread().getName()+"正在"+str[i]+"，要等五分钟,厕所只能一个人");
						try {
							Thread.sleep(50);
						} catch (InterruptedException e) {
							
							e.printStackTrace();
						}
					}
				}
				else
				{
					System.out.println(Thread.currentThread().getName()+"正在"+str[i]+"，需五分钟");
					try {
						Thread.sleep(50);
					} catch (InterruptedException e) {
						
						e.printStackTrace();
					}
				}
			}
			System.out.println(Thread.currentThread().getName()+"上好了");
	}	
	
	

}